function download_git_installer() {
	$git_for_windows_url = "https://mirrors.tuna.tsinghua.edu.cn/github-release/git-for-windows/git/Git%20for%20Windows%20v2.49.0.windows.1/Git-2.49.0-64-bit.exe"
	$downloads = $env:UserProfile + "\Downloads"
	$git_for_windows_installer = $downloads + "\Git-2.49.0-64-bit.exe" 
	if ( Test-Path -Path $git_for_windows_installer ) {
		Write-Host "File $git_for_windows_installer already exists."
	} else {
		Write-Host "File $git_for_windows_installer not exists, downloading"
		iwr $git_for_windows_url -o $git_for_windows_installer
	}
	return $git_for_windows_installer
}

function install_git() {
	$git_location = "C:\Programs\Git"
	if (-not (Test-Path -Path $git_location)) {
		New-Item -Path $git_location
	}
	if (-not (Test-Path -Path "C:\Program Files\Git")) {
		New-Item -Name Git -Path "C:\Program Files\Git" -Type Junction -Value $git_location 
	}
	$git_executable = $git_location + "\bin\git.exe"
	if ( -not (Test-Path -Path $git_executable) ) {
		download_git_installer | Invoke-Item
	}
}

function config_git() {
}

install_git

function install_winget() {
	if (Get-Command winget -ErrorAction SilentlyContinue) {
		Write-Host "winget is already installed"
	} else {
		$progressPreference = 'silentlyContinue'
		Write-Host "Installing WinGet PowerShell module from PSGallery..."
		Install-PackageProvider -Name NuGet -Force | Out-Null
		Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null
		Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..."
		Repair-WinGetPackageManager
		Write-Host "Done."
		# Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe
	}
	winget install Microsoft.WinGet.Client
}

function config_winget() {
	$winget_source = "https://mirrors.ustc.edu.cn/winget-source"
	winget source add ustc $winget_source
}

install_winget | config_winget

function download_rime_installer() {
	$rime_url = "https://github.com/rime/weasel/releases/download/0.16.3/weasel-0.16.3.0-installer.exe"

}

